//
//  ZYXLeaveMsgVC.m
//  RuiBeiKang
//
//  Created by iOS开发1 on 2019/1/10.
//  Copyright © 2019年 JW. All rights reserved.
//

#import "ZYXLeaveMsgVC.h"

@interface ZYXLeaveMsgVC ()<UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UITextView *textView;

@property (weak, nonatomic) IBOutlet UILabel *plLabel;
@end

@implementation ZYXLeaveMsgVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.textView.delegate = self;
    self.title = @"一键反馈";
}

#pragma mark textView
//正在改变
- (void)textViewDidChange:(UITextView *)textView {
    self.plLabel.hidden = YES;
    //字数限制操作
    if (textView.text.length >= 140) {
        textView.text = [textView.text substringToIndex:140];
    }
    //取消按钮点击权限，并显示提示文字
    if (textView.text.length == 0) {
        self.plLabel.hidden = NO;
    }
}
- (IBAction)clickSubBtn:(UIButton *)sender {
    NSLog(@"点击提交按钮");
    if(self.textView.text.length == 0){
        [JKToast showWithText:@"您还没有填写任何内容"];
        return;
    }else{
        [NetWork POSTWithUrlString:kInterfaceAllUrl(PATH_WDLEAVEMsg) parmas:@{@"user_id":UID,@"content":self.textView.text} successBloock:^(NSDictionary *responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] isEqualToNumber:@200]) {
                
                [JKToast showWithText:@"反馈成功"];
                [self.navigationController popViewControllerAnimated:YES];
                
            }else{
                [JKToast showWithText:responseObject[@"message"]];
            }
            
            
        } failureBlock:^(NSError *error) {
            
        }];
    }
}

@end
